﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using motelmanagement.common;
using System.Data.OleDb;
using System.Data;
namespace motelmanagement.dao
{
    class ExtraPriceDAO
    {
        SqlUtil sqlUtil = new SqlUtil();
        OleDbCommand cmd = null;
        private string strSql = null;

        public DataTable getAllExtraPrice()
        {
            cmd = new OleDbCommand("Select * from Extra_price");
            sqlUtil.Load(cmd);
            return sqlUtil;
        }
        public DataTable getExtraPrice(int extraID)
        {
            cmd = new OleDbCommand("Select * from Extra_price Where extra_id=@id");
            cmd.Parameters.Add("id", SqlDbType.Int).Value = extraID;
            sqlUtil.Load(cmd);
            return sqlUtil;
        }
        public void insertExtraPrice(string extraName, int extraPrice, string extraNote)
        {
            strSql = "Insert into Extra_price(extra_name,extra_price,extra_note)";
            strSql += " Values(@name,@price,@note)";
            cmd = new OleDbCommand(strSql);
            cmd.Parameters.Add("name", SqlDbType.NText).Value = extraName;
            cmd.Parameters.Add("price", SqlDbType.Int).Value = extraPrice;
            cmd.Parameters.Add("note", SqlDbType.NText).Value = extraNote;
            sqlUtil.ExecuteNoneQuery(cmd);
        }
        public void updateExtraPrice(int extraID, string extraName, int extraPrice, string extraNote)
        {
            strSql = "Update Extra_price Set extra_name=@name,extra_price=@price,extra_note=@note";
            strSql += " Where extra_id=@id";
            cmd = new OleDbCommand(strSql);
            cmd.Parameters.Add("name", SqlDbType.NText).Value = extraName;
            cmd.Parameters.Add("price", SqlDbType.Int).Value = extraPrice;
            cmd.Parameters.Add("note", SqlDbType.NText).Value = extraNote;
            cmd.Parameters.Add("id", SqlDbType.Int).Value = extraID;
            sqlUtil.ExecuteNoneQuery(cmd);
        }
        public void deleteExtraPrice(int extraID)
        {
            strSql = "Delete From Extra_price Where extra_id=@id";
            cmd = new OleDbCommand(strSql);
            cmd.Parameters.Add("id", SqlDbType.Int).Value = extraID;
            sqlUtil.ExecuteNoneQuery(cmd);
        }
    }
}
